from Base.Base import Base
from selenium.webdriver.common.by import By
from Common.Api_client import ApiClient
class Page3_pay_add_selecrt_product(Base):
    def __init__(self, driver):
        super().__init__(driver)
        self.client = ApiClient()
    # 支付管理模块
    def click_pay(self):
        by, value = self.client.get_locator("pay", "pay_loc")
        self.click((by, value))
    # 支付产品信息
    def click_pay_product(self):
        by, value = self.client.get_locator("pay", "pay_product_loc")
        self.click((by, value))

    # 添加支付产品按钮
    def click_product_add(self):
        by, value = self.client.get_locator("pay", "product_add_loc")
        self.click((by, value))
    # 支付产品编码
    def send_product_code(self, product_code):
        by, value = self.client.get_locator("pay", "product_code_loc")
        self.send_keys((by, value),product_code)
    # 支付产品名称
    def send_product_name(self, product_name):
        by, value = self.client.get_locator("pay", "product_name_loc")
        self.send_keys((by, value),product_name)
    # 支付产品提交按钮
    def click_product_save(self):
        by, value = self.client.get_locator("pay", "product_save_loc")
        self.click((by, value))
    # # 弹窗确认框
    # def click_que(self):
    #     by, value = self.client.get_locator("alert", "que_loc")
    #     self.click((by, value))
    # 支付产品名称搜索框
    def send_find_name(self, product_name):
        by, value = self.client.get_locator("pay", "product_find_loc")
        self.send_keys((by, value),product_name)
    # 支付产品搜索按钮
    def click_search_btn(self):
        by, value = self.client.get_locator("pay", "product_search_btn_loc")
        self.click((by, value))
    # 获取搜索后放回的支付商商品的名称
    def get_searched_product_name(self):
        by, value = self.client.get_locator("pay", "searched_product_name_loc")
        return  self.get_location_text((by, value))

    # 弹窗返回内容
    def get_tean_text(self):
        by, value = self.client.get_locator("alert", "tan_text_loc")
        print(by, value)
        return self.get_location_text((by, value))

    # 弹窗确定按钮

    def click_que(self):
        by, value = self.client.get_locator("alert", "que_loc")
        self.click((by, value))
